package com.jiangruan.javaproject;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.address.Address;
import com.jiangruan.javaproject.bean.HotVideo;
import com.jiangruan.javaproject.bean.HotVideoCommon;
import com.jiangruan.javaproject.bean.NBAGame;
import com.jiangruan.javaproject.bean.RPCCommon;
import com.jiangruan.javaproject.request.HttpUtils;
import com.jiangruan.javaproject.rpc.GetBestBlockHash;
import com.jiangruan.javaproject.service.HotVideoService;
import com.jiangruan.javaproject.service.NBAGameService;

import java.security.KeyPair;
import java.util.List;
import java.util.Scanner;

/**
 * @author:SAVA ME(未蒙救赎)
 * @email:1902586238@qq.com
 * @desc:
 * @datetime:2021/12/20 20:56
 **/
public class Main {

    public static void main(String []args){
        run();
    }

    public static void run(){
        System.out.println("===========比特币系统设计期末考查系统===========");
        System.out.println("此系统可以实现多种功能，如：");
        System.out.println("0.退出 1.热门视频抓取 2.和比特币客户端通信 3.比特币地址推导 4.NBA赛事");
        while (true){
            userMenu();
        }
    }

    public static void userMenu(){
        System.out.println("请输入序号进行选择");
        System.out.println("0.退出 1.热门你视频抓取 2.和比特币客户端通信 3.比特币地址推导");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1: //热门视频抓取
                HotVideoService hotVideo = new HotVideoService();
                List<HotVideo> videoList = hotVideo.getHotVideo();
                for (HotVideo video :videoList){
                    System.out.println("视频标题：");
                    System.out.println(video.getTitle());
                    System.out.println("视频地址：");
                    System.out.println(video.getShare_url());
                    System.out.println("视频发布者昵称：");
                    System.out.println(video.getAuthor());
                    System.out.println("视频封面图：");
                    System.out.println(video.getItem_cover());
                    System.out.println("热度指数：");
                    System.out.println(video.getHot_value());
                    System.out.println("视频热词：");
                    System.out.println(video.getHot_words());
                    System.out.println("播放数：");
                    System.out.println(video.getPlay_count());
                    System.out.println("点赞数：");
                    System.out.println(video.getDigg_count());
                    System.out.println("评论数：");
                    System.out.println(video.getComment_count());
                }
                break;
            case 2:
                GetBestBlockHash getBestBlockHash = new GetBestBlockHash();
                RPCCommon bestBlockHash = getBestBlockHash.getBestBlockHash();
                System.out.println(bestBlockHash.getResult());
                break;
            case 3:
                Address addr = new Address();
                KeyPair keyPair = addr.generateKeys();
                String address = addr.newAddress(keyPair);
                boolean isValid = addr.validateAddr(address);
                System.out.println(isValid);
                break;
            case 4:
                NBAGameService nbaGameService = new NBAGameService();
                List<NBAGame> nbaGameList = nbaGameService.getNBAGame();
                for (NBAGame game: nbaGameList){
                    System.out.println(game.matchs);
                }
                break;
            case 0:
                System.out.println("感谢使用此系统");
                System.exit(0);;
                break;
            default:
                System.out.println("输入错误，重新进行输入");
                break;
        }
    }
}
